<?php
/*

Class MSN search
@author Rana

*/

class MSN {
	
	//All search request URLs start with the hostname and resemble the following sample:
	var $hostname;
	
	var $baseurl;

	var $livesite;


	function MSN() {
		$this->hostname = $GLOBALS['msn_hostname'];
		$this->livesite = $GLOBALS['msn_live'];
		$this->baseurl = $this->hostname;
	}
	
	function frame_link($url) {
		$this->baseurl .= $url;
	}
	
	function get_response($url) {
		if (empty($url)) return false;
		//$this->frame_link($url);
		$url = $this->baseurl . $url;

		$contents = file_get_contents($url);
		
		$results = 0;
		
		if ($contents !== false) {
			$regexp = $GLOBALS['msn_regexp'];
			$contents = strip_tags($contents);
			
			if (preg_match($regexp, $contents, $matches) ) {
				//print_r($matches);
				if (isset($matches[2])) {
					$results = str_replace(",","",$matches[2]);
				}
			} 
		
		}
		return $results;
	}

	//
	function get_url($value, $url) {
		$url = '<a href="'.$this->livesite.$url.'" title="MSN" class="link1" target="_blank">'.$value.'</a>';

		return $url;
	}
}

?>